package org.come.Frame;

import com.tool.tcpimg.UIUtils;
import org.come.Jpanel.ZhuShouJpanel;
import org.come.until.FormsManagement;
import org.come.until.Music;

import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class ZhuShouJframe extends JInternalFrame implements MouseListener {
    private int first_x,first_y;
    private ZhuShouJpanel zhuShouJpanel = new ZhuShouJpanel();

    public static ZhuShouJframe getZhuShouJframe() {
        return (ZhuShouJframe) FormsManagement.getInternalForm(113).getFrame();
    }

    public ZhuShouJframe() {
        this.add(this.zhuShouJpanel);
        this.setBorder(BorderFactory.createEmptyBorder());
        ((BasicInternalFrameUI)this.getUI()).setNorthPane(null);
        this.setBounds(200, 60, 862, 411);
        this.setOpaque(false);
        this.pack();
        this.setBackground(UIUtils.Color_BACK);
        this.setVisible(false);
        this.addMouseMotionListener(new MouseMotionListener() {
            public void mouseMoved(MouseEvent e) {
            }

            public void mouseDragged(MouseEvent e) {
                if (ZhuShouJframe.this.isVisible()) {
                    int x = e.getX() - ZhuShouJframe.this.first_x;
                    int y = e.getY() - ZhuShouJframe.this.first_y;
                    ZhuShouJframe.this.setBounds(x + ZhuShouJframe.this.getX(), y + ZhuShouJframe.this.getY(), ZhuShouJframe.this.getWidth(), ZhuShouJframe.this.getHeight());
                }

            }
        });
        this.addMouseListener(this);
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {
        Music.addyinxiao("关闭窗口.mp3");
        if (e.isMetaDown()) {
            FormsManagement.HideForm(113);
        } else {
            FormsManagement.Switchinglevel(113);
        }

        this.first_x = e.getX();
        this.first_y = e.getY();
    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    public ZhuShouJpanel getZhuShouJpanel() {
        return zhuShouJpanel;
    }
}
